#!/bin/bash

# 删除kylin系统自带java
update-alternatives --remove-all java

# 注：JDK版本要求大于等于1.8，这里使用1.8.0_201
mkdir -p /usr/java/ && tar -zxvf jdk-8u201-linux-x64.tar.gz -C /usr/java/
cp -rf jdk1.8.0_201 default

# 配置环境变量
echo "export JAVA_HOME=/usr/java/default" >> /etc/profile
echo "export JRE_HOME=${JAVA_HOME}/jre" >> /etc/profile
echo "export CLASSPATH=:${JAVA_HOME}/lib:${JRE_HOME}/lib:CLASS_PATH=$JAVA_HOME/jre/lib/ext/gdal.jar:$CLASS_PATH$CLASSPATH" >> /etc/profile
echo "export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin" >> /etc/profile
echo "export PATH=$PATH:${JAVA_PATH}" >> /etc/profile

source /etc/profile
